/********************************
 creater:tianhuixia
 create time:2017-8
 describe：登录页
 modify time:
 ********************************/
RRSApp.controller('LoginController', ['$scope',
  function ($scope) {
    $scope.$on('$ionicView.enter', function () {
      $scope.w = Math.min(document.documentElement.clientWidth, window.innerWidth);
      $scope.h = Math.min(document.documentElement.clientHeight, window.innerHeight);
      $scope.itemw = Math.min($scope.w/6);
      console.log($scope.w);
      console.log($scope.h);
      $scope.itemsa =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.itemsb =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.itemsc =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.itemsd =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.itemse =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.itemsf =[{index:0,isTrue:'a'},{index:1,isTrue:'a'},{index:2,isTrue:'a'}];
      $scope.begin = true;
      $scope.clickDesc='开始占卜';
      $scope.selectedSite='事业';
      $scope.sites =[
        {site : "事业"},
        {site : "财运"},
        {site : "官运"}
      ];
      $scope.init();
    });

    $scope.init = function () {

    };
    $scope.goTurn = function () {
      if ($scope.begin) {
        $scope.begin = false;
        $scope.clickDesc = '停止';
        angular.forEach($scope.itemsa, function (data,index) {
          data.isTrue = 'c';
        });
        angular.forEach($scope.itemsb, function (data,index) {
          data.isTrue = 'c';
        });
        angular.forEach($scope.itemsc, function (data,index) {
          data.isTrue = 'c';
        });
        angular.forEach($scope.itemsd, function (data,index) {
          data.isTrue = 'c';
        });
        angular.forEach($scope.itemse, function (data,index) {
          data.isTrue = 'c';
        });
        angular.forEach($scope.itemsf, function (data,index) {
          data.isTrue = 'c';
        });
      } else {
        $scope.begin = true;
        $scope.clickDesc = '开始占卜';
        angular.forEach($scope.itemsa, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
        angular.forEach($scope.itemsb, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
        angular.forEach($scope.itemsc, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
        angular.forEach($scope.itemsd, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
        angular.forEach($scope.itemse, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
        angular.forEach($scope.itemsf, function (data,index) {
          var randomNum = Math.round(Math.random());
          if(randomNum ==0){
            data.isTrue = 'a';
          }else if(randomNum ==1){
            data.isTrue = 'b';
          }
        });
      }
    }
  }
]);
